package com.gc.frontend.web.action.ajax;

import com.alibaba.fastjson.JSONObject;
import com.gc.common.entity.History;
import com.gc.common.entity.HistoryPositionBusiness;
import com.gc.frontend.service.HistoryPositionBusinessService;
import com.gc.frontend.service.HistoryService;
import com.gc.common.util.ReturnJsonUtil;

import java.util.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/ajax/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @Autowired
    private HistoryPositionBusinessService historyPositionBusinessService;

    @RequestMapping("/getHistroies")
    @ResponseBody
    public JSONObject getHistories(String carImei) {
        List<History> histories = historyService.selectHistoryByCarImei(carImei);
        return ReturnJsonUtil.successRows(histories);
    }

    @RequestMapping("/getHistoryPositions")
    @ResponseBody
    public JSONObject getHistoryPositions(Integer historyId) {
        List<HistoryPositionBusiness> historyPositions =
                historyPositionBusinessService.selectHistoryPositionByHistoryId(historyId);
        return ReturnJsonUtil.successRows(historyPositions);
    }
}